package plg.grupo1.Lexico.StateMachineHierarchy;

import plg.grupo1.Lexico.TokenHierarchy.TokenError;

public class State6 implements State{
	
    private static State6 INSTANCE = null;    
	private State6(){}
	
    private synchronized static void createInstance() {
        if (INSTANCE == null) INSTANCE = new State6();
    }
    
    public static State6 getInstance() {
        if (INSTANCE == null) createInstance();
        return INSTANCE;
    }
    
    public void goNext(){
				
		if(Contexto.isEof()){
			Contexto.clearLexema();
			Contexto.addError(new TokenError("ERROR en linea " + Contexto.getCurrentLineN()
					+ " expected HEX-CHARARCTER but Found EOF"));
			Contexto.setCurrentState(State9.getInstance());
		}
		else{
			
			char c = Contexto.getCharAndMoveToNext();//A
			Contexto.appendToLexema(c);//B
			
			if("0123456789abcdef".indexOf(Character.toLowerCase(c))!=-1)
				Contexto.setCurrentState(State7.getInstance());
			else{
				//error
				Contexto.addError(new TokenError("ERROR en linea " + Contexto.getCurrentLineN()
							+ " expected NUMERO but Found "
							+ Contexto.getLexema() + " + '" + c + "'"));
				Contexto.clearLexema();
				Contexto.setCurrentState(State0.getInstance());
			}
		}
	}
}